package com.xpgk.mvc.statistic.spropagandaTraining;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.constant.ConstantSplitPage;
import com.xpgk.dto.SplitPage;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.statistic.customerInfo.CustomerInfoStatisticXLS;
import com.xpgk.mvc.statistic.monthNursing.MonthNursingStatisticSQL;
import com.xpgk.mvc.user.User;
import com.xpgk.tools.ToolDateTime;



public class SpropagandaTrainingController extends BaseController {
	
	private  SpropagandaTrainingService  spropagandaTrainingService;
	
	public  void  index(){	
		Organization organ=Organization.dao.findById(getCUserOrganIds());
		setAttr("organization", organ);
		setAttr("startTime", ToolDateTime.getMonthOneDay(new Date()));
		render("spropagandaTraining.html");
	}
	
	/*
	 * 宣传查询
	 */
	public void queryPropaganda(){
		String json = paging(splitPage, SpropagandaTrainingSQL.sqlId_splitPageSelect, SpropagandaTrainingSQL.sqlId_splitPageFrom);
		renderJson(json);
	}
	/**数据导出
	 * 
	 */
	public  void  excel()
	{	
		SplitPage  splitPage=new SplitPage();
		String organIds = getPara("organIds");
		String minTime = getPara("minTime");
		String maxTime = getPara("maxTime");
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("organIds", organIds);
		param.put("minTime", minTime);
		param.put("maxTime", maxTime);
		splitPage.setPageSize(ConstantSplitPage.default_maxSize);
		splitPage.setQueryParam(param);
		String json = paging(splitPage, SpropagandaTrainingSQL.sqlId_splitPageSelect, SpropagandaTrainingSQL.sqlId_splitPageFrom);
		List<Record>  list=(List<Record>)splitPage.getList();
		//搜索条件
		Organization  organ = Organization.dao.findById(organIds);
		String  search="日期："+minTime+"~"+maxTime+",门店："+organ.getStr(Organization.column_name)+",导出人员："+getCUser().getStr(User.column_name);
		render(new SpropagandaTrainingXLS(list,search,"宣传活动表"));
	}
}
